<template>
  <div class="dashboard">
    <!-- 顶部标题栏 -->
    <header class="dashboard-header">
      <div class="title">
        <Monitor class="el-icon" />
        智慧农业大棚监控系统
      </div>
      <div class="time">
        <Timer class="el-icon" />
        {{ currentTime }}
      </div>
    </header>

    <!-- 主要内容区域 -->
    <div class="dashboard-content">
      <!-- 左侧面板 -->
      <div class="left-panel">
        <GreenhouseInfo />
        <DeviceStats />
        <WeatherInfo />
      </div>

      <!-- 中间面板 -->
      <div class="center-panel">
        <VideoMonitor />
        <EnvironmentData />
      </div>

      <!-- 右侧面板 -->
      <div class="right-panel">
        <DataCharts />
        <HistoryImages />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
import { Monitor, Timer } from '@element-plus/icons-vue'
import GreenhouseInfo from '../components/GreenhouseInfo.vue'
import DeviceStats from '../components/DeviceStats.vue'
import WeatherInfo from '../components/WeatherInfo.vue'
import VideoMonitor from '../components/VideoMonitor.vue'
import EnvironmentData from '../components/EnvironmentData.vue'
import DataCharts from '../components/DataCharts.vue'
import HistoryImages from '../components/HistoryImages.vue'

const currentTime = ref(new Date().toLocaleString())
let timer

onMounted(() => {
  timer = setInterval(() => {
    currentTime.value = new Date().toLocaleString()
  }, 1000)
})

onUnmounted(() => {
  clearInterval(timer)
})
</script>

<style scoped>
.dashboard {
  width: 100vw;
  height: 100vh;
  color: #fff;
  padding: 20px;
  box-sizing: border-box;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  height: 60px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  margin-bottom: 20px;
}

.title {
  font-size: 24px;
  font-weight: bold;
  color: #42b983;
  display: flex;
  align-items: center;
  gap: 10px;
}

.time {
  display: flex;
  align-items: center;
  gap: 5px;
}

.dashboard-content {
  display: grid;
  grid-template-columns: 350px 1fr 350px;
  gap: 20px;
  height: calc(100vh - 100px);
}

.left-panel,
.center-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

:deep(.el-icon) {
  vertical-align: middle;
}
</style> 